home *** CD-ROM | disk | FTP | other *** search
/ The Best of MacTutor - S…e Code for Volumes 1 to 5 / The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin / Source Code / #06 (Feb 86) / pascal 2.2 / Play_Clip_Wave < prev    next >
Text File  |  1985-12-20  |  1KB  |  58 lines

  1. program Play_Clip_Wave;
  2.  type
  3.   Ptr = ^integer;
  4.   ParamBlockFake = array[0..30] of integer;
  5.  
  6.   MySynthH = ^MySynthP;
  7.   MySynthP = ^FFSynthRec;
  8.  
  9.  var
  10.   waveH : MySynthH;
  11.  
  12.   TheType, offset, Size : Longint;
  13.   str : str255;
  14.  
  15.   blockA, blockB : ParamBlockFake;
  16.   AUsed : boolean;
  17.  
  18.  procedure MyStartSound (SynthRec : ptr;
  19.          numbytes : longint;
  20.          CompletionRtn : Ptr);
  21.   var
  22.    regs : array[0..12] of longint; { for generic }
  23.    BlockPtr : ^ParamBlockFake;
  24.  begin
  25.   if Aused then
  26.    BlockPtr := @BlockA
  27.   else
  28.    BlockPtr := @BlockB;
  29.   Aused := not Aused;
  30.  
  31.   BlockPtr^[12] := -4;{ set ioRefNum }
  32.   BlockMove(@SynthRec, @BlockPtr^[16], 4);{ ioBuffer }
  33.   BlockMove(@numbytes, @BlockPtr^[18], 4);{ ioReqCount }
  34.  
  35.   while BlockPtr^[8] <> 0 do { wait for ioResult }
  36.    ;
  37. { The following two lines perform  PBWrite(BlockPtr,true) }
  38.   regs[0] := ord(BlockPtr);{ set A0 for generic }
  39.   Generic($A403, regs);{ Write,async }
  40.  end;
  41.  
  42. begin
  43.  ShowText;
  44.  waveH := NewHandle(12);
  45.  str := 'WAVE';
  46.  BlockMove(@str[1], @TheType, 4);{ TheType:='WAVE' }
  47.  size := LinlineF($A9FD, waveH, TheType, @offset);{ GetScrap }
  48.  
  49.  if size > 0 then
  50.   begin
  51.    repeat
  52.     MyStartSound(waveH^, size - 6, nil);
  53.    until button;
  54.    StopSound;
  55.   end
  56.  else
  57.   writeln('no scrap of type ''WAVE'' is available');
  58. end.